## 指定镜像
FROM  php:7.2-fpm

## 维护者信息
MAINTAINER lico "1065107664@qq.com"

## 运行用户，默认root
# ENV RUN_USER php 
## 设置组
# ENV RUN_GROUP php
## 数据文件夹
# ENV DATA_DIR /data
## 日志文件夹
# ENV LOG_DIR /log

## 设置时区
ENV TZ=Asia/Shanghai
# RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

## 可以先进入容器查看php已经有了哪些扩展: php -m ,例如下
## Core,ctype,curl,date,dom,fileinfo,filter,ftp,hash,iconv,json,
## libxml,mbstring,mysqlnd,openssl,pcre,PDO,pdo_sqlite,Phar,posix,
## readline,Reflection,session,SimpleXML,sodium,SPL,sqlite3,standard,
## tokenizer,xml,xmlreader,xmlwriter,zlib

RUN apt-get update

## docker 官方扩展
RUN docker-php-ext-install -j$(nproc) bcmath calendar exif gettext sockets dba mysqli pcntl pdo_mysql shmop sysvmsg sysvsem sysvshm

# bz2
RUN apt-get install -y --no-install-recommends \
libbz2-dev \
&& docker-php-ext-install -j$(nproc) bz2

# gd
RUN apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd

# intl
# RUN apt-get install -y --no-install-recommends \
# libicu-dev \
# && docker-php-ext-install -j$(nproc) intl

# mcrypt
# RUN apt-get install -y --no-install-recommends \
# libmcrypt-dev \
# && pecl install mcrypt-1.0.1 && docker-php-ext-enable mcrypt

# igbinary
RUN pecl install igbinary && docker-php-ext-enable igbinary

# xdebug
RUN pecl install xdebug && docker-php-ext-enable xdebug

# gmp
# RUN apt-get install -y --no-install-recommends libgmp-dev \
# && docker-php-ext-install -j$(nproc) gmp

# soap wddx xmlrpc tidy xsl
# RUN apt-get install -y --no-install-recommends \
# libxml2-dev \
# libtidy-dev \
# libxslt1-dev \
# && docker-php-ext-install -j$(nproc) soap wddx xmlrpc tidy xsl

# pgsql pdo_pgsql 
# RUN apt-get install -y --no-install-recommends \
# libpq-dev \
# && docker-php-ext-install -j$(nproc) pgsql pdo_pgsql

# zip
# RUN apt-get install -y --no-install-recommends \
# libzip-dev \
# && docker-php-ext-install -j$(nproc) zip

# memcached 
RUN apt-get install -y --no-install-recommends \
libmemcached-dev \
zlib1g-dev \
&& pecl install memcached && docker-php-ext-enable memcached

# redis
RUN pecl install redis && docker-php-ext-enable redis

# opcache
RUN docker-php-ext-configure opcache --enable-opcache && docker-php-ext-install opcache

## 清除临时扩展文件
RUN apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \
&& docker-php-source delete

## cmd 用于执行容器启动后的命令，只能出现一次，所以用脚本
# RUN chmod 775 /run.sh
# CMD ["/run.sh"]

EXPOSE 9000

CMD ["php-fpm", "-F"]